import os
import gui, ui, wx
from gui.settingsDialogs import NVDASettingsDialog
from . import adb, baidu, caiyun, constants, exchangeRate, fund, nvtts, screen, settings, stock, watcher, webView
from .ocr import getOcrRecognizer, vCodeRecognizer, vSlideRecognizer, xfCurrencyRecognizer, xfPlaceRecognizer, xfSceneRecognizer
# 宝盒设置对话框
def menu_setting():
    def show (evt):
        gui.mainFrame._popupSettingsDialog (NVDASettingsDialog, settings.SettingsPanel)
    wx.CallAfter(show, None)
# 验证码识别
def menu_vcode():
    vCodeRecognizer.start()
# 滑块验证识别
def menu_vslide():
    vSlideRecognizer.start()
# OCR 识别
def menu_ocr():
    ocrRecognizer = getOcrRecognizer()
    if not ocrRecognizer:return
    ocrRecognizer.start()
#物体识别
def menu_currency():
    xfCurrencyRecognizer.start()
# 场所识别
def menu_place():
    xfPlaceRecognizer.start()
# 场景识别
def menu_scene():
    xfSceneRecognizer.start()
# 查看天气
def menu_weather():
    caiyun.broadcastWeather()
# 查看基金
def menu_fund():
    fund.viewFund()
# 查看股票
def menu_stock():
    stock.viewStock()
# 查看汇率
def menu_exchangeRate():
    exchangeRate.viewExchangeRate()
# 安卓截图和识别
def menu_screenshot():
    adb.screenshot()
# 安卓截图到剪贴板
def menu_screenshotToClipboard():
    adb.screenshotToClipboard()
# 安卓安装 APP
def menu_installApp():
    adb.installApp()
# 打开安卓设置
def menu_openAndroidSettings():
    adb.shell('am start com.android.settings/.Settings')
# 对象截图到剪贴板
def menu_navigatorObjectScreenshot():
    screen.navigatorObjectScreenshot()
# 识别剪贴板图像
def menu_clipBitmapRecog():
    screen.recogClipBitmap()
# 翻译剪贴板文本
def menu_translateFromClipboard():
    baidu.translateFromClipboard()
# 激活内嵌网页
def menu_activateEmbeddedWebView ():
    webView.activateFromCurrentWindow ()

# 对象监视
def menu_watchNavigatorObject ():
    watcher.watchNavigatorObject ()
# 切换NVTTS连接状态
def menu_nvttsSwitch():
    nvtts.switch()
# 宝盒帮助
def menu_help():
    selfDir = os.path.dirname (__file__)
    readmeFile = os.path.join (selfDir, '..', '..', 'doc', 'zh_CN', 'readme.html')
    with open (readmeFile, 'r', encoding = constants.CHARSET) as f:
        ui.browseableMessage (f.read (), 'NV宝盒帮助说明', True)
